//
//  WJFMDBController.m
//  JerryIos
//
//  Created by 王军 on 2018/2/15.
//  Copyright © 2018年 王军. All rights reserved.
//

#import "WJFMDBController.h"
#import "WJFmdbUtils.h"
#import "WJFmdbData.h"

@interface WJFMDBController ()

@end

@implementation WJFMDBController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (IBAction)insertData:(id)sender {
    WJFmdbData *data = [[WJFmdbData alloc] init];
    data.name = @"aaa";
    data.age = 12;
    
    [WJFmdbUtils addData:data];
}

- (IBAction)updateData:(id)sender {
    WJFmdbData *data = [[WJFmdbData alloc] init];
    data.id = 1;
    data.name = @"aaabbb";
    data.age = 13;
    
    [WJFmdbUtils updateData:data];
}

- (IBAction)deleteData:(id)sender {
    [WJFmdbUtils deleteData:1];
}

- (IBAction)selectAllData:(id)sender {
    NSArray *dataArray = [WJFmdbUtils data];
    for (WJFmdbData *data in dataArray) {
        NSLog(@"id=%i,   name=%@,   age=%i", data.id, data.name, data.age);
    }
}

- (IBAction)insertDataArray:(id)sender {
    WJFmdbData *data1 = [[WJFmdbData alloc] init];
    data1.name = @"aaa";
    data1.age = 11;
    
    WJFmdbData *data2 = [[WJFmdbData alloc] init];
    data2.name = @"bbb";
    data2.age = 22;
    
    WJFmdbData *data3 = [[WJFmdbData alloc] init];
    data3.name = @"ccc";
    data3.age = 33;
    
    NSMutableArray *mutDataArray = [NSMutableArray array];
    [mutDataArray addObject:data1];
    [mutDataArray addObject:data2];
    [mutDataArray addObject:data3];
    
    [WJFmdbUtils addDataArray:mutDataArray];
    
}

- (IBAction)updateDataArray:(id)sender {
    WJFmdbData *data1 = [[WJFmdbData alloc] init];
    data1.id = 1;
    data1.name = @"aaa444";
    data1.age = 11;
    
    WJFmdbData *data2 = [[WJFmdbData alloc] init];
    data2.id = 2;
    data2.name = @"bbb555";
    data2.age = 22;
    
    NSMutableArray *mutDataArray = [NSMutableArray array];
    [mutDataArray addObject:data1];
    [mutDataArray addObject:data2];
    
    [WJFmdbUtils updateDataArray:mutDataArray];
}

- (IBAction)deleteDataArray:(id)sender {
    NSMutableArray *mutDataArray = [NSMutableArray array];
    [mutDataArray addObject:@"1"];
    [mutDataArray addObject:@"2"];
    
    [WJFmdbUtils deleteDataArray:mutDataArray];
}


@end
